package cn.kgc.web;

import cn.kgc.pojo.User;
import cn.kgc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    public String userLogin(String code, String password, HttpSession session){
        User user = userService.login(code, password);
        if (user == null){
            return "devlogin";
        }else{
            //将登录用户保存到会话中
            session.setAttribute("loginUser",user);
            return "redirect:/developer/appinfolist";
        }
    }

}
